﻿using MediatR;
using System.CJL.API.Application.Command.StorageCommand;
using System.CJL.Infrstructre.Interface;

namespace System.CJL.API.Application.CommandHanlder.StorageCommandHandler
{
	/// <summary>
	/// 修改状态
	/// </summary>
	public class StorageUpdateStatusCommandHandler : IRequestHandler<StorageUpdateStatusCommand, int>
	{
        IStorageRepository _storageRepository;
		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="storageRepository"></param>
        public StorageUpdateStatusCommandHandler(IStorageRepository storageRepository)
        {
			_storageRepository=storageRepository;

		}
		/// <summary>
		/// 修改
		/// </summary>
		/// <param name="request"></param>
		/// <param name="cancellationToken"></param>
		/// <returns></returns>
		public async Task<int> Handle(StorageUpdateStatusCommand request, CancellationToken cancellationToken)
		{
			var list = await _storageRepository.GetMondel(request.id);
			list.Status = true;
			return await _storageRepository.UpdateAsync(list);
		}
	}
}
